#!/usr/bin/env python
# encoding: utf-8
"""
ep2.py

Created by Luciano Ramalho on 2007-05-09.
"""
import sys

def raiz_quadrada(x, epsilon):
    chute = x
    chute_ant = 0
    while abs(chute-chute_ant) > epsilon:
        chute_ant = chute
        chute = (chute + x/chute) / 2.0
    return chute


epsilon = float(sys.stdin.readline())
n = int(sys.stdin.readline())
assert n >= 1
print "                    Raizes de Equacoes Quadraticas"
print "-------------------------------------------------------------------------------"
print "     coeficientes       tipo das"
print "   a      b      c      solucoes       raiz 1                raiz 2"
print "-------------------------------------------------------------------------------"

for i in range(n):
    a,b,c = [float(x) for x in sys.stdin.readline().split()]
    msg = None
    if a < epsilon:
        msg = "*** ERRO: equacao nao e do segundo grau! ***"
    else:
        r1 = r2 = 0.0
        r1_imag = r2_imag = 0.0
        delta = b*b-4.0*a*c
        if delta >= 0.0:
            raiz2delta = raiz_quadrada(delta, epsilon)
            r1_imag_str = ""
            r2_imag_str = ""
            r1 = (-b + raiz2delta) / (2.0 * a)
            if abs(raiz2delta) < epsilon:
                tipo = "real dupla"
                r2 = r1
            else: # delta significativo:
                tipo = "reais simples"
                r2 = (-b - raiz2delta) / (2.0 * a)
        else: # delta negativo
            tipo = "complexas"
            r1 = r2 = -b / (2.0*a)
            r1_imag = raiz_quadrada( 4.0*a*c-b*b, epsilon) / (2.0*a)
            r1_imag_str = " + i*%.4f" % r1_imag
            r2_imag_str = " - i*%.4f" % r1_imag
        msg =  "%-13s %8.4f%-13s %8.4f%s" % (tipo, r1, r1_imag_str, r2, r2_imag_str)
    print "%6.2f %6.2f %6.2f   %s" % (a, b, c, msg)
    
    
